package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysDogType;
import com.ruoyi.project.system.service.ISysDogTypeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 电子狗种类Controller
 * 
 * @author ruoyi
 * @date 2020-08-04
 */
@RestController
@RequestMapping("/system/type")
public class SysDogTypeController extends BaseController
{
    @Autowired
    private ISysDogTypeService sysDogTypeService;

    /**
     * 查询电子狗种类列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDogType sysDogType)
    {
        startPage();
        List<SysDogType> list = sysDogTypeService.selectSysDogTypeList(sysDogType);
        return getDataTable(list);
    }

    /**
     * 导出电子狗种类列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "电子狗种类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysDogType sysDogType)
    {
        List<SysDogType> list = sysDogTypeService.selectSysDogTypeList(sysDogType);
        ExcelUtil<SysDogType> util = new ExcelUtil<SysDogType>(SysDogType.class);
        return util.exportExcel(list, "type");
    }

    /**
     * 获取电子狗种类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysDogTypeService.selectSysDogTypeById(id));
    }

    /**
     * 新增电子狗种类
     */
    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "电子狗种类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDogType sysDogType)
    {
        return toAjax(sysDogTypeService.insertSysDogType(sysDogType));
    }

    /**
     * 修改电子狗种类
     */
    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "电子狗种类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDogType sysDogType)
    {
        return toAjax(sysDogTypeService.updateSysDogType(sysDogType));
    }

    /**
     * 删除电子狗种类
     */
    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "电子狗种类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysDogTypeService.deleteSysDogTypeByIds(ids));
    }
}
